package com.chuqiyun.authorization.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chuqiyun.authorization.dao.ProductDao;
import com.chuqiyun.authorization.entity.Product;
import com.chuqiyun.authorization.service.ProductService;
import org.springframework.stereotype.Service;

/**
 * 产品(Product)表服务实现类
 *
 * @author mryunqi
 * @since 2023-04-19 17:07:26
 */
@Service("productService")
public class ProductServiceImpl extends ServiceImpl<ProductDao, Product> implements ProductService {

    /**
    * @Author: mryunqi
    * @Description: 获取单个产品信息
    * @DateTime: 2023/4/19 23:00
    * @Params: String name 产品名
    * @Return Product
    */
    @Override
    public Product getProduct(String name) {
        QueryWrapper<Product> productQueryWrapper = new QueryWrapper<>();
        productQueryWrapper.eq("name", name);
        return this.getOne(productQueryWrapper);
    }

    /**
     * @Author: mryunqi
     * @Description: 根据授权码查询授权信息
     * @DateTime: 2023/5/13 11:53
     * @Params: String code 在线授权码
     * @Return Product
     */
    @Override
    public Product getProductByCode(String code) {
        QueryWrapper<Product> productQueryWrapper = new QueryWrapper<>();
        productQueryWrapper.eq("product_code", code);
        return this.getOne(productQueryWrapper);
    }
}

